export {}

declare global {
    interface NumberConstructor {
        format: any;
        safe: any;
        fixed: any;
    }
}


Number.format =
    Number.format ||
    ((n, decimals = 0) => {
        const factor = Math.pow(10, decimals);
        return Math.round(n * factor) / factor;
    });

Number.safe =
    Number.safe ||
    ((n, decimals = 0) => {
        return Number(n.toFixed(decimals));
    });

Number.fixed =
    Number.fixed ||
    ((n, decimals = 0) => {
        let [int, float = '0'] = n.toString().split('.');
        float = float.slice(0, decimals).padEnd(decimals, 0);
        return Number(`${int}.${float}`);
    });
